package com.yunche.yunchebusiness.api

import com.google.gson.JsonArray
import com.google.gson.JsonObject
import com.yunche.yunchebusiness.base.BaseResponse
import com.yunche.yunchebusiness.entity.*
import io.reactivex.Observable
import okhttp3.RequestBody
import retrofit2.http.*

/**
 * Create by Crcker on 2018/12/20 11:16
 * Email: Crcker@163.com
 */


interface ApiService {


    //获取品牌车系车型
    @Headers("${Api.URL_TYPE_KEY}:${Api.URL_TYPE_COMMON}", "${Api.PORT_TYPE_KEY}:${Api.COMMON}")
    @GET("api/car/brand")
    fun getBrand(): Observable<BaseResponse<JsonArray>>

    @Headers("${Api.URL_TYPE_KEY}:${Api.URL_TYPE_COMMON}", "${Api.PORT_TYPE_KEY}:${Api.COMMON}")
    @POST("api/car/series")
    fun getSeries(@Body body: RequestBody): Observable<BaseResponse<List<SeriesEntity>>>

    @Headers("${Api.URL_TYPE_KEY}:${Api.URL_TYPE_COMMON}", "${Api.PORT_TYPE_KEY}:${Api.COMMON}")
    @POST("api/car/model")
    fun getModel(@Body body: RequestBody): Observable<BaseResponse<List<ModelEntity>>>

    //登录
    @POST("login")
    fun login(@Body body: RequestBody): Observable<BaseResponse<LoginEntity>>

    @GET("app/index")
    fun getHomePage(): Observable<BaseResponse<HomeEntity>>

    //修改密码
    @POST("app/system/user")
    fun changePwd(@Body body: RequestBody): Observable<BaseResponse<LoginEntity>>

    //提现
    @POST("app/finance/detail")
    fun saveFinance(@Body body: RequestBody): Observable<BaseResponse<String>>

    //获取银行列表
    @POST("app/system/bank/list")
    fun getBankList(@Body requestBody: RequestBody): Observable<BaseResponse<List<BankListEntity>>>

    @GET("/app/tenant/account")
    fun getTenantBankList(): Observable<BaseResponse<List<TenantBankList>>>

    @GET("app/system/bank")
    fun getAvailableBank(): Observable<BaseResponse<List<BankList>>>

    @GET("app/finance/account")
    fun getTotalPrice(): Observable<BaseResponse<FinanceEntity>>

    //获取省市
    @GET("app/system/area/list")
    fun getAreaList(): Observable<BaseResponse<List<AreaEntity>>>

    //获取商户信息
    @GET("app/system/tenant")
    fun getTenantInfo(): Observable<BaseResponse<TenantInfoEntity>>

    //获取用户信息
    @GET("app/system/user")
    fun getUserInfo(): Observable<BaseResponse<UserEntity>>

    //保存商户信息
    @PUT("app/system/tenant/{tenantId}")
    fun submitTenantInfo(@Body requestBody: RequestBody, @Path("tenantId") id: String): Observable<BaseResponse<String>>

    @PUT("app/system/tenant")
    fun changeTenantInfo(@Body requestBody: RequestBody): Observable<BaseResponse<String>>

    //获取车辆颜色
    @Headers("${Api.URL_TYPE_KEY}:${Api.URL_TYPE_COMMON}", "${Api.PORT_TYPE_KEY}:${Api.COMMON}")
    @GET("/api/car/color/{modelId}")
    fun getColor(@Path("modelId") modelId: String): Observable<BaseResponse<ColorEntity>>

    //获取估价
    @Headers("${Api.URL_TYPE_KEY}:${Api.URL_TYPE_COMMON}", "${Api.PORT_TYPE_KEY}:${Api.COMMON}")
    @POST("/api/car/evaluate")
    fun getEvaluate(@Body body: RequestBody): Observable<BaseResponse<EvaluateEntity>>

    //获取估价列表
    @GET("app/eveluate/record")
    fun getEvaluateRecord(): Observable<BaseResponse<List<EvaluateRecord>>>

    //保存估价列表
    @POST("app/eveluate/record")
    fun saveEvaluateRecord(@Body requestBody: RequestBody): Observable<BaseResponse<String>>

    //获取订单列表
    @GET("app/account/order/list/{date}")
    fun getOrderList(
        @Path("date") date: String,
        @Query("curPage") curPage: Int
    ): Observable<BaseResponse<AccountBookBaseInfoMainEntity>>

    //获取资金明细列表
    @POST("app/finance/detail/list/{date}")
    fun getFinanceList(
        @Path("date") date: String,
        @Body requestBody: RequestBody
    ): Observable<BaseResponse<AccountBookBaseInfoMainEntity>>

    //账本首页基础信息
    @GET("app/account/order/index/{date}")
    fun getFinanceBaseInfo(@Path("date") date: String): Observable<BaseResponse<AccountBookBaseInfo>>

    //账本首页基础信息
    @GET("app/account/order/index/list")
    fun getFinanceBaseInfoList(@Query("date") date: String): Observable<BaseResponse<List<AccountBookBaseInfo>>>

    //账本订单详情
    @GET("app/account/order/{orderId}")
    fun getOrderDetail(@Path("orderId") orderId: String): Observable<BaseResponse<AccountBookEntity>>

    //账本资金详情
    @GET("app/finance/detail/{id}")
    fun getFinanceDetail(@Path("id") id: Long): Observable<BaseResponse<AccountBookEntity>>

    //版本更新检测
    @Headers("${Api.URL_TYPE_KEY}:${Api.URL_TYPE_BASE}", "${Api.PORT_TYPE_KEY}:${Api.CHECH_VERSION}")
    @POST("api/app/version/check?appName=yunche_api_tenant_app_")
    fun checkVersion(@Body requestBody: RequestBody): Observable<JsonObject>

    @DELETE("/app/eveluate/record/{id}")
    fun deleteEvaluate(@Path("id") id: Int): Observable<BaseResponse<String>>
}